<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('用户分配子账号')" />
</head>
<body>
    <div class="main-content">
        <form id="form-user-add" class="form-horizontal">
            <input type="hidden" id="userId" name="userId" th:value="${user.userId}">
            <h4 class="form-header h4">基本信息</h4>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">用户名称：</label>
                        <div class="col-sm-8">
                            <input name="userName" class="form-control" type="text" disabled th:value="${user.userName}">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">登录账号：</label>
                        <div class="col-sm-8">
                            <input name="loginName" class="form-control" type="text" disabled th:value="${user.loginName}">
                        </div>
                    </div>
                </div> 
            </div>
           
            <h4 class="form-header h4">分配子账号</h4>
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-12 select-table table-striped">
					    <table id="bootstrap-table"></table>
					</div>
                </div>
            </div>
        </form>
    </div>
      
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
        var reciprefix = ctx + "business/recipientInfo";
        var typedata = [[${@dict.getType('channel_type')}]];

        $(function() {
            var options = {
                url: reciprefix + "/serviceRecipList",
                modalName: "收款账号",
                pageList: [5,10,25,50,100,200,500],
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: '',
                        visible: false
                    },
                    {
                        field: 'userName',
                        title: '码商名称/分组',
                        formatter: function(value, row, index) {
                            return ('<span style="color: green;">'+row.userName+ '</span></br><span style="color: red;">' + (row.groupName== null ? '无分组' : row.groupName )+"</span>")
                        }
                    },
                    // {
                    //     field: 'platformIs',
                    //     title: '是否平台收款账号'
                    // },
                    {
                        field: 'channelType',
                        title: '通道类型',
                        formatter: function(value, item, index) {
                            return $.table.selectDictLabel(typedata, item.channelType);
                        }
                    },
                    {
                        field: 'channelName',
                        title: '通道名称'
                    },

                    {
                        field: 'channelAccount',
                        title: '通道账号'
                    },
                    {
                        field: 'realName',
                        title: '账号别名'
                    }]
            };
            $.table.init(options);
		});
	    
	    /* 添加角色-提交 */
        function submitHandler(index, layero){
            var rows = $.table.selectFirstColumns();
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
        	$.operate.saveTab(reciprefix + "/serviceRecip", { "userId": $("#userId").val(), "ids": rows.join() });
        }
    </script>
</body>
</html>